from scipy import interpolate
import numpy as np
from Sector_Parameters import *
Nr,Nt,Nz,dr,dt,dz,Np,NN,Nx,Nw,Ny,Nv,N_p, Nx_aug,sigma_pnts=circular_parameters()
DeltaT, Tsim, Nsim=time_parameters()

Nt_new = 85
Nr_new = 146
def create_interpolate(x,y):
    f_cubic=interpolate.Rbf(x,y,kind='linear')
    #f_cubic=interpolate.Akima1DInterpolator(x,y)
    return f_cubic

def values_interpolate(x_new,x_old,y_old):
    F_cubicCur=create_interpolate(x_old,y_old)
    y_new=F_cubicCur(x_new)
    return y_new

def new_values(Z_old):
    Nt = 17
    x_old = np.arange(0, 300, 10)
    x_new = np.linspace(0, 290, Nr_new)
    z_new=[]
    for i in range(Nt):
        z_cur=Z_old[i,:]
        z_values=values_interpolate(x_new,x_old,z_cur)
        z_new.append(z_values)
    Z_new=np.array(z_new)
    return Z_new

def new_values_radial(Z_old):
    x_old = np.linspace(0, np.pi/2, 17)
    x_new = np.linspace(0, np.pi/2, Nt_new)
    z_new=[]
    Z_old = np.transpose(Z_old)
    for i in range(Nr_new):
        z_cur=Z_old[i,:]
        z_values=values_interpolate(x_new,x_old,z_cur)
        z_new.append(z_values)
    Z_new=np.array(z_new)
    return Z_new